Skip to content

fix(chat): catch up resumed sessions by persisted cursor - #95

Merged
kahme247 merged 4 commits into
ompweb-dev:mainfrom
andrebrait:fix/session-catch-up
Sep 14, 2026
Merged

kahme247 merged 4 commits into
ompweb-dev:mainfrom
andrebrait:fix/session-catch-up

Conversation

@andrebrait

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to merged #94 and #61: a reconnected stream could deliver new tokens while silently omitting messages saved during the gap.

  • Add paged context?sync=1 catch-up using persisted entry IDs, with branch/compaction reset fallback and page-only blob resolution.
  • Keep confirmed history separate from optimistic input and live output. Completed history is fetch-since-only; SSE completion frames trigger catch-up instead of appending unidentified duplicates.
  • Cache quiet partial/tool snapshots in the web-owned wrapper, with stream epochs and selective message/tool/lifecycle ordering.
  • A new completion during an in-flight fetch schedules a reread from the newly returned cursor. Existing file notifications cover native completion arriving before persistence.
  • Preserve drafts, selected historical views, real errors, terminal tree metadata, and upstream capped idle reconnect backoff.
  • Normalize test-loader file URL aliases for Windows singleton-module identity.

No WebSocket switch, native OMP upgrade, SDK import, new dependency, or replay journal.

Verification

  • Current-upstream npm test: 744 passed, 1 existing platform-specific skip.
  • Typecheck and lint passed.
  • Explicit concurrent-completion regressions cover persistence before and after a held HTTP reply, advanced cursors, distinct IDs with identical text, and newer partial preservation.
  • Real Chromium mobile smoke with actual Next HTTP/SSE/file watcher and a controlled native NDJSON process: cursor 3 recovers entries 4/5/6 only; explicitly closed stream; quiet partial restored by HTTP without a replayed token; final answer committed once.
  • Condensed adversarial review: no blocking findings; delayed provider-error backstop regression added.

Deployment

Frontend and API support must be deployed together. This change is not deployed yet.

@andrebrait

Copy link
Copy Markdown
Collaborator Author

Review fixes are in 059fe34: run-scoped response evidence covers terminal-before-persistence, file-only catch-up refreshes metadata without overwriting newer RPC choices, replacement observer streams restore registrations/roster, and bounded byte-offset indexes avoid rescanning unchanged history per page.

Verified: 763 local tests passed (one existing platform skip), typecheck/lint/production build passed, and Linux + Windows CI are green. Re-ran the real-browser offline/reconnect scenario through actual HTTP/SSE with a controlled native NDJSON fixture: all missed IDs recovered, no confirmed-prefix resend, quiet partial restored without a new token, final answer once, zero page errors. A physical 270 MiB history benchmark read only page bodies on later requests and zero message bytes for a completed cursor.

Matching fork review-only PR: andrebrait/ompweb#24. Updated Copilot and CodeRabbit reviews requested there. No deployment performed.

@andrebrait

Copy link
Copy Markdown
Collaborator Author

Final head 3e5c24d passes Linux and Windows CI. Updated review findings are resolved: atomic complete-history publication, safe full-load precedence after truncation, retryable failed state reads, and ID-only pre-prompt boundaries. Mutable-file index rebuilds remain deliberately correctness-first because growth cannot certify an unchanged prefix; that tradeoff is documented.

The reviewed feature was integrated with the existing local queue/dialog patch stack and deployed locally from clean deploy/integration commit 371892f. Integration verification: 818 passed, one existing platform skip; typecheck/lint/production build passed; real browser retained a 410-entry complete history while replacement page two was held. Public frontend consumed the cursor API while the existing native run remained active. Matching frontend/API deployed, native executable unchanged, old RPC owners preserved until they drain. Fork review mirror remains unmerged.

@kahme247
kahme247 merged commit 2cac1b1 into ompweb-dev:main Sep 14, 2026
3 checks passed
@andrebrait
andrebrait deleted the fix/session-catch-up branch September 14, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants